﻿using System;
using System.Configuration;
using System.Xml;
using WeiSha.Core.Param.Method;

namespace WeiSha.Core
{
	// Token: 0x02000022 RID: 34
	public class PlatformInfoHandler : IConfigurationSectionHandler
	{
		// Token: 0x0600010A RID: 266 RVA: 0x00008094 File Offset: 0x00006294
		object IConfigurationSectionHandler.Create(object parent, object configContext, XmlNode section)
		{
			return section;
		}

		// Token: 0x0600010B RID: 267 RVA: 0x000080A8 File Offset: 0x000062A8
		public static XmlNode GetParaNode(string xpath)
		{
			object section = ConfigurationManager.GetSection("Platform");
			XmlElement xmlElement = section as XmlElement;
			return xmlElement.SelectSingleNode(xpath);
		}

		// Token: 0x0600010C RID: 268 RVA: 0x000080D8 File Offset: 0x000062D8
		public static PlatformInfoHandler.SiteInfoHandlerParaNode Node(string xpath)
		{
			object section = ConfigurationManager.GetSection("Platform");
			XmlElement xmlElement = section as XmlElement;
			bool flag = xmlElement == null;
			PlatformInfoHandler.SiteInfoHandlerParaNode siteInfoHandlerParaNode;
			if (flag)
			{
				siteInfoHandlerParaNode = null;
			}
			else
			{
				XmlNode xmlNode = xmlElement.SelectSingleNode(xpath);
				bool flag2 = xmlNode == null;
				if (flag2)
				{
					siteInfoHandlerParaNode = null;
				}
				else
				{
					PlatformInfoHandler.SiteInfoHandlerParaNode siteInfoHandlerParaNode2 = new PlatformInfoHandler.SiteInfoHandlerParaNode(xmlNode);
					siteInfoHandlerParaNode = siteInfoHandlerParaNode2;
				}
			}
			return siteInfoHandlerParaNode;
		}

		// Token: 0x02000047 RID: 71
		public class SiteInfoHandlerParaNode
		{
			// Token: 0x17000105 RID: 261
			// (get) Token: 0x060002CD RID: 717 RVA: 0x000134D8 File Offset: 0x000116D8
			public string Key
			{
				get
				{
					return this._key;
				}
			}

			// Token: 0x17000106 RID: 262
			// (get) Token: 0x060002CE RID: 718 RVA: 0x000134F0 File Offset: 0x000116F0
			public ConvertToAnyValue Value
			{
				get
				{
					return new ConvertToAnyValue(this._value);
				}
			}

			// Token: 0x17000107 RID: 263
			// (get) Token: 0x060002CF RID: 719 RVA: 0x00013510 File Offset: 0x00011710
			public PlatformInfoHandler.SiteInfoHandlerParaNode FirstChildren
			{
				get
				{
					bool flag = this._list.Count < 1;
					PlatformInfoHandler.SiteInfoHandlerParaNode siteInfoHandlerParaNode;
					if (flag)
					{
						siteInfoHandlerParaNode = null;
					}
					else
					{
						siteInfoHandlerParaNode = new PlatformInfoHandler.SiteInfoHandlerParaNode(this._list[0]);
					}
					return siteInfoHandlerParaNode;
				}
			}

			// Token: 0x17000108 RID: 264
			// (get) Token: 0x060002D0 RID: 720 RVA: 0x0001354C File Offset: 0x0001174C
			public PlatformInfoHandler.SiteInfoHandlerParaNode[] Children
			{
				get
				{
					bool flag = this._list.Count < 1;
					PlatformInfoHandler.SiteInfoHandlerParaNode[] array;
					if (flag)
					{
						array = null;
					}
					else
					{
						PlatformInfoHandler.SiteInfoHandlerParaNode[] array2 = new PlatformInfoHandler.SiteInfoHandlerParaNode[this._list.Count];
						for (int i = 0; i < this._list.Count; i++)
						{
							array2[i] = new PlatformInfoHandler.SiteInfoHandlerParaNode(this._list[i]);
						}
						array = array2;
					}
					return array;
				}
			}

			// Token: 0x060002D1 RID: 721 RVA: 0x000135B8 File Offset: 0x000117B8
			public PlatformInfoHandler.SiteInfoHandlerParaNode GetChildren(string key)
			{
				bool flag = this._list.Count < 1;
				PlatformInfoHandler.SiteInfoHandlerParaNode siteInfoHandlerParaNode;
				if (flag)
				{
					siteInfoHandlerParaNode = null;
				}
				else
				{
					PlatformInfoHandler.SiteInfoHandlerParaNode siteInfoHandlerParaNode2 = null;
					PlatformInfoHandler.SiteInfoHandlerParaNode[] children = this.Children;
					for (int i = 0; i < children.Length; i++)
					{
						bool flag2 = !string.Equals(children[i].Attribute("key"), key, StringComparison.CurrentCultureIgnoreCase);
						if (!flag2)
						{
							siteInfoHandlerParaNode2 = children[i];
						}
					}
					siteInfoHandlerParaNode = siteInfoHandlerParaNode2;
				}
				return siteInfoHandlerParaNode;
			}

			// Token: 0x060002D2 RID: 722 RVA: 0x0001362C File Offset: 0x0001182C
			public SiteInfoHandlerParaNode(XmlNode node)
			{
				XmlNodeList xmlNodeList = node.SelectNodes("./item");
				this._list = xmlNodeList;
				this._node = node;
				this._key = ((node.Attributes["key"] != null) ? node.Attributes["key"].Value : "");
				this._value = ((node.Attributes["value"] != null) ? node.Attributes["value"].Value : "");
			}

			// Token: 0x060002D3 RID: 723 RVA: 0x000136C4 File Offset: 0x000118C4
			public string Attribute(string attr)
			{
				return (this._node.Attributes[attr] != null) ? this._node.Attributes[attr].Value : "";
			}

			// Token: 0x060002D4 RID: 724 RVA: 0x00013708 File Offset: 0x00011908
			public ConvertToAnyValue AttrValue(string attr)
			{
				string text = this.Attribute(attr);
				return new ConvertToAnyValue(text);
			}

			// Token: 0x17000109 RID: 265
			public PlatformInfoHandler.SiteInfoHandlerParaNode this[string key]
			{
				get
				{
					bool flag = this._list == null;
					PlatformInfoHandler.SiteInfoHandlerParaNode siteInfoHandlerParaNode;
					if (flag)
					{
						siteInfoHandlerParaNode = null;
					}
					else
					{
						XmlNode xmlNode = null;
						foreach (object obj in this._list)
						{
							XmlNode xmlNode2 = (XmlNode)obj;
							bool flag2 = xmlNode2.Attributes["key"].Value.ToLower() == key.Trim().ToLower();
							if (flag2)
							{
								xmlNode = xmlNode2;
								break;
							}
						}
						bool flag3 = xmlNode == null;
						if (flag3)
						{
							siteInfoHandlerParaNode = null;
						}
						else
						{
							siteInfoHandlerParaNode = new PlatformInfoHandler.SiteInfoHandlerParaNode(xmlNode);
						}
					}
					return siteInfoHandlerParaNode;
				}
			}

			// Token: 0x060002D6 RID: 726 RVA: 0x000137E8 File Offset: 0x000119E8
			public string ItemValue(string key)
			{
				string text = "";
				bool flag = this._list == null;
				string text2;
				if (flag)
				{
					text2 = text;
				}
				else
				{
					foreach (object obj in this._list)
					{
						XmlNode xmlNode = (XmlNode)obj;
						bool flag2 = xmlNode == null;
						if (!flag2)
						{
							bool flag3 = xmlNode.Attributes["key"] == null;
							if (!flag3)
							{
								bool flag4 = xmlNode.Attributes["key"].Value.ToLower() == key.Trim().ToLower();
								if (flag4)
								{
									text = xmlNode.Attributes["value"].Value;
									break;
								}
							}
						}
					}
					text2 = text;
				}
				return text2;
			}

			// Token: 0x040000E0 RID: 224
			private XmlNodeList _list;

			// Token: 0x040000E1 RID: 225
			private XmlNode _node;

			// Token: 0x040000E2 RID: 226
			private string _key;

			// Token: 0x040000E3 RID: 227
			private string _value;
		}
	}
}
